using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;


using System.Data.Linq;
using System.Linq;

using DataLayer;

namespace BusinessLayer.Activities
{
   public partial class Update_TabColumnWidths : System.Workflow.ComponentModel.Activity
   {
      public Update_TabColumnWidths()
      {
         //InitializeComponent();
      }

      private static DependencyProperty TabIdProperty = DependencyProperty.Register("TabId", typeof(int), typeof(Update_TabColumnWidths));
      public int TabId
      {
         get { return (int)base.GetValue(TabIdProperty); }
         set { base.SetValue(TabIdProperty, value); }
      }

      private static DependencyProperty C1Property = DependencyProperty.Register("C1", typeof(byte), typeof(Update_TabColumnWidths));
      public byte C1
      {
         get { return (byte)base.GetValue(C1Property); }
         set { base.SetValue(C1Property, value); }
      }

      private static DependencyProperty C2Property = DependencyProperty.Register("C2", typeof(byte), typeof(Update_TabColumnWidths));
      public byte C2
      {
         get { return (byte)base.GetValue(C2Property); }
         set { base.SetValue(C2Property, value); }
      }

      private static DependencyProperty C3Property = DependencyProperty.Register("C3", typeof(byte), typeof(Update_TabColumnWidths));
      public byte C3
      {
         get { return (byte)base.GetValue(C3Property); }
         set { base.SetValue(C3Property, value); }
      }

      private static DependencyProperty C4Property = DependencyProperty.Register("C4", typeof(byte), typeof(Update_TabColumnWidths));
      public byte C4
      {
         get { return (byte)base.GetValue(C4Property); }
         set { base.SetValue(C4Property, value); }
      }
      private static DependencyProperty innerHTMLProperty = DependencyProperty.Register("innerHTML", typeof(string), typeof(Update_TabColumnWidths));
      public string innerHTML
      {
         get { return (string)base.GetValue(innerHTMLProperty); }
         set { base.SetValue(innerHTMLProperty, value); }
      }

      protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
      {
         using (var db = DatabaseHelper.GetDashboardData())
         {
            var tab = db.Tabs.Single(p => p.ID == TabId);
            tab.PanelWidth_1 = C1;
            tab.PanelWidth_2 = C2;
            tab.PanelWidth_3 = C3;
            tab.PanelWidth_4 = C4;
            tab.InnerHTML = innerHTML;
            db.SubmitChanges();
         }
         return ActivityExecutionStatus.Closed;
      }
   }
}